package entities;

import java.awt.Color;
import java.awt.Font;

/** The class that represents the remaining ammunition in the brick breaker game.
 * @author Team 1
 *
 */
@SuppressWarnings("serial")
public class AmmunitionCounter extends Entity {

	private Font font;			//The font of the label.
	
	/** The constructor of the Ammunition counter.
	 * @param x : The x coordinate of the upper left corner.
	 * @param y : The y coordinate of the upper left corner.
	 * @param xScale : The x resize scale. If it's lower than one it reduces the images original width, increase it otherwise.
	 * @param yScale : the y resize scale. If it's lower than one it reduces the images original, increase it otherwise.
	 * Obviously if scales are equals to one it doesn't resize.
	 * @param ammo : The value of the ammo to display.
	 */
	public AmmunitionCounter(int x, int y, float xScale, float yScale, int ammo) {
		super(x, y);
		font = new Font("Helvetica", Font.PLAIN, Math.round(12 * xScale));
		this.setFont(font);
		width = Math.round(25 * xScale);
		height = Math.round(font.getSize() * 1.5f);
		if(ammo == 0) {
			setText(null);
		} else {
			setText("" + ammo);
		}
		setForeground(Color.WHITE);
		setBounds(x, y, width, height);
	}
	
	/** Set's the remaining ammunition number and shows it if it's higher than zero.
	 * @param ammo : remaining ammunition number.
	 */
	public void setAmmoCounter(int ammo) {
		if(ammo == 0) {
			setText(null);
		} else {
			setText("" + ammo);
		}
	}
}